home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / a-strunb.adb < prev    next >
Text File  |  1996-01-30  |  22KB  |  818 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                A D A . S T R I N G S . U N B O U N D E D                 --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.11 $                             --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. --  Note: This code is derived from the ADAR.CSH public domain Ada 83
  27. --  versions of the Appendix C string handling packages.
  28.  
  29. with Ada.Strings.Fixed;
  30. with Ada.Strings.Search;
  31. with Ada.Unchecked_Deallocation;
  32.  
  33. package body Ada.Strings.Unbounded is
  34.  
  35.    ---------
  36.    -- "=" --
  37.    ---------
  38.  
  39.    function "=" (Left, Right : in Unbounded_String) return Boolean is
  40.    begin
  41.       return Left.Reference.all = Right.Reference.all;
  42.    end "=";
  43.  
  44.    function "="
  45.      (Left  : in Unbounded_String;
  46.       Right : in String)
  47.       return  Boolean
  48.    is
  49.       UBRight : Unbounded_String;
  50.  
  51.    begin
  52.       UBRight := (Reference => new String (1 .. Right'Length));
  53.       UBRight.Reference.all := Right;
  54.       return Left.Reference.all = UBRight.Reference.all;
  55.    end "=";
  56.  
  57.    function "="
  58.      (Left  : in String;
  59.       Right : in Unbounded_String)
  60.       return  Boolean
  61.    is
  62.       UBLeft : Unbounded_String;
  63.  
  64.    begin
  65.       UBLeft := (Reference => new String (1 .. Left'Length));
  66.       UBLeft.Reference.all := Left;
  67.       return UBLeft.Reference.all = Right.Reference.all;
  68.    end "=";
  69.  
  70.    ---------
  71.    -- "<" --
  72.    ---------
  73.  
  74.    function "<" (Left, Right : in Unbounded_String) return Boolean is
  75.    begin
  76.       return Left.Reference.all < Right.Reference.all;
  77.    end "<";
  78.  
  79.    function "<"
  80.      (Left  : in Unbounded_String;
  81.       Right : in String)
  82.       return  Boolean
  83.    is
  84.       UBRight : Unbounded_String;
  85.  
  86.    begin
  87.       UBRight := (Reference => new String (1 .. Right'Length));
  88.       UBRight.Reference.all := Right;
  89.       return Left.Reference.all < UBRight.Reference.all;
  90.    end "<";
  91.  
  92.    function "<"
  93.      (Left  : in String;
  94.       Right : in Unbounded_String)
  95.       return  Boolean
  96.    is
  97.       UBLeft : Unbounded_String;
  98.  
  99.    begin
  100.       UBLeft := (Reference => new String (1 .. Left'Length));
  101.       UBLeft.Reference.all := Left;
  102.       return UBLeft.Reference.all < Right.Reference.all;
  103.    end "<";
  104.  
  105.    ----------
  106.    -- "<=" --
  107.    ----------
  108.  
  109.    function "<=" (Left, Right : in Unbounded_String) return Boolean is
  110.    begin
  111.       return Left.Reference.all <= Right.Reference.all;
  112.    end "<=";
  113.  
  114.    function "<="
  115.      (Left  : in Unbounded_String;
  116.       Right : in String)
  117.       return  Boolean
  118.    is
  119.       UBRight : Unbounded_String;
  120.  
  121.    begin
  122.       UBRight := (Reference => new String (1 .. Right'Length));
  123.       UBRight.Reference.all := Right;
  124.       return Left.Reference.all <= UBRight.Reference.all;
  125.    end "<=";
  126.  
  127.    function "<="
  128.      (Left  : in String;
  129.       Right : in Unbounded_String)
  130.       return  Boolean
  131.    is
  132.       UBLeft : Unbounded_String;
  133.  
  134.    begin
  135.       UBLeft := (Reference => new String (1 .. Left'Length));
  136.       UBLeft.Reference.all := Left;
  137.       return UBLeft.Reference.all <= Right.Reference.all;
  138.    end "<=";
  139.  
  140.    ---------
  141.    -- ">" --
  142.    ---------
  143.  
  144.    function ">"  (Left, Right : in Unbounded_String) return Boolean is
  145.    begin
  146.       return Left.Reference.all > Right.Reference.all;
  147.    end ">";
  148.  
  149.    function ">"
  150.      (Left  : in Unbounded_String;
  151.       Right : in String)
  152.       return  Boolean
  153.    is
  154.       UBRight : Unbounded_String;
  155.  
  156.    begin
  157.       UBRight := (Reference => new String (1 .. Right'Length));
  158.       UBRight.Reference.all := Right;
  159.       return Left.Reference.all > UBRight.Reference.all;
  160.    end ">";
  161.  
  162.    function ">"
  163.      (Left  : in String;
  164.       Right : in Unbounded_String)
  165.       return  Boolean
  166.    is
  167.       UBLeft : Unbounded_String;
  168.  
  169.    begin
  170.       UBLeft := (Reference => new String (1 .. Left'Length));
  171.       UBLeft.Reference.all := Left;
  172.       return UBLeft.Reference.all > Right.Reference.all;
  173.    end ">";
  174.  
  175.    ----------
  176.    -- ">=" --
  177.    ----------
  178.  
  179.    function ">=" (Left, Right : in Unbounded_String) return Boolean is
  180.    begin
  181.       return Left.Reference.all >= Right.Reference.all;
  182.    end ">=";
  183.  
  184.    function ">="
  185.      (Left  : in Unbounded_String;
  186.       Right : in String)
  187.       return  Boolean
  188.    is
  189.       UBRight : Unbounded_String;
  190.  
  191.    begin
  192.       UBRight := (Reference => new String (1 .. Right'Length));
  193.       UBRight.Reference.all := Right;
  194.       return Left.Reference.all >= UBRight.Reference.all;
  195.    end ">=";
  196.  
  197.    function ">="
  198.      (Left  : in String;
  199.       Right : in Unbounded_String)
  200.       return  Boolean
  201.    is
  202.       UBLeft : Unbounded_String;
  203.  
  204.    begin
  205.       UBLeft := (Reference => new String (1 .. Left'Length));
  206.       UBLeft.Reference.all := Left;
  207.       return UBLeft.Reference.all >= Right.Reference.all;
  208.    end ">=";
  209.  
  210.    ---------
  211.    -- "*" --
  212.    ---------
  213.  
  214.    function "*"
  215.      (Left  : Natural;
  216.       Right : Character)
  217.       return  Unbounded_String
  218.    is
  219.       Result : Unbounded_String := (Reference => new String (1 .. Left));
  220.  
  221.    begin
  222.       Result.Reference.all := (1 .. Left => Right);
  223.       return Result;
  224.    end "*";
  225.  
  226.    function "*"
  227.      (Left  : Natural;
  228.       Right : String)
  229.      return   Unbounded_String
  230.    is
  231.       Result : Unbounded_String :=
  232.          (Reference => new String (1 .. Left * Right'Length));
  233.  
  234.    begin
  235.       for J in 1 .. Left loop
  236.          Result.Reference.all
  237.            (Right'Length * J - Right'Length + 1 .. Right'Length * J) := Right;
  238.       end loop;
  239.  
  240.       return Result;
  241.    end "*";
  242.  
  243.    function "*"
  244.      (Left  : Natural;
  245.       Right : Unbounded_String)
  246.       return  Unbounded_String
  247.    is
  248.       R_Length : constant Integer := Right.Reference.all'Length;
  249.       Result   : Unbounded_String :=
  250.         (Reference => new String (1 .. Left * Right.Reference.all'Length));
  251.  
  252.    begin
  253.       for I in 1 .. Left loop
  254.          Result.Reference.all (R_Length * I - R_Length + 1 .. R_Length * I) :=
  255.            Right.Reference.all;
  256.       end loop;
  257.  
  258.       return Result;
  259.    end "*";
  260.  
  261.    ---------
  262.    -- "&" --
  263.    ---------
  264.  
  265.    function "&" (Left, Right : Unbounded_String) return Unbounded_String is
  266.       L_Length : constant Integer := Left.Reference.all'Length;
  267.       R_Length : constant Integer := Right.Reference.all'Length;
  268.       Length   : constant Integer :=  L_Length + R_Length;
  269.       Result   : Unbounded_String := (Reference => new String (1 .. Length));
  270.  
  271.    begin
  272.       Result.Reference.all (1 .. L_Length)          := Left.Reference.all;
  273.       Result.Reference.all (L_Length + 1 .. Length) := Right.Reference.all;
  274.       return Result;
  275.    end "&";
  276.  
  277.    function "&"
  278.      (Left  : Unbounded_String;
  279.       Right : String)
  280.       return  Unbounded_String
  281.    is
  282.       L_Length : constant Integer := Left.Reference.all'Length;
  283.       Length   : constant Integer := L_Length +  Right'Length;
  284.       Result   : Unbounded_String := (Reference => new String (1 .. Length));
  285.  
  286.    begin
  287.       Result.Reference.all (1 .. L_Length)          := Left.Reference.all;
  288.       Result.Reference.all (L_Length + 1 .. Length) := Right;
  289.       return Result;
  290.    end "&";
  291.  
  292.    function "&"
  293.      (Left  : String;
  294.       Right : Unbounded_String)
  295.       return  Unbounded_String
  296.    is
  297.       R_Length : constant Integer := Right.Reference.all'Length;
  298.       Length   : constant Integer := Left'Length + R_Length;
  299.       Result   : Unbounded_String := (Reference => new String (1 .. Length));
  300.  
  301.    begin
  302.       Result.Reference.all (1 .. Left'Length)          := Left;
  303.       Result.Reference.all (Left'Length + 1 .. Length) := Right.Reference.all;
  304.       return Result;
  305.    end "&";
  306.  
  307.    function "&"
  308.      (Left  : Unbounded_String;
  309.       Right : Character)
  310.       return  Unbounded_String
  311.    is
  312.       Length : constant Integer := Left.Reference.all'Length + 1;
  313.       Result : Unbounded_String := (Reference => new String (1 .. Length));
  314.  
  315.    begin
  316.       Result.Reference.all (1 .. Length - 1) := Left.Reference.all;
  317.       Result.Reference.all (Length)          := Right;
  318.       return Result;
  319.    end "&";
  320.  
  321.    function "&"
  322.      (Left  : Character;
  323.       Right : Unbounded_String)
  324.       return  Unbounded_String
  325.    is
  326.       Length : constant Integer := Right.Reference.all'Length + 1;
  327.       Result : Unbounded_String := (Reference => new String (1 .. Length));
  328.  
  329.    begin
  330.       Result.Reference.all (1)           := Left;
  331.       Result.Reference.all (2 .. Length) := Right.Reference.all;
  332.       return Result;
  333.    end "&";
  334.  
  335.    -----------
  336.    -- Count --
  337.    -----------
  338.  
  339.    function Count
  340.      (Source   : Unbounded_String;
  341.       Pattern  : String;
  342.       Mapping  : Maps.Character_Mapping := Maps.Identity)
  343.       return     Natural
  344.    is
  345.    begin
  346.       return Search.Count (Source.Reference.all, Pattern, Mapping);
  347.    end Count;
  348.  
  349.    function Count
  350.      (Source   : in Unbounded_String;
  351.       Pattern  : in String;
  352.       Mapping  : in Maps.Character_Mapping_Function)
  353.       return     Natural
  354.    is
  355.    begin
  356.       return Search.Count (Source.Reference.all, Pattern, Mapping);
  357.    end Count;
  358.  
  359.    function Count
  360.      (Source   : Unbounded_String;
  361.       Set      : Maps.Character_Set)
  362.       return     Natural
  363.    is
  364.    begin
  365.       return Search.Count (Source.Reference.all, Set);
  366.    end Count;
  367.  
  368.    ------------
  369.    -- Delete --
  370.    ------------
  371.  
  372.    function Delete
  373.      (Source  : Unbounded_String;
  374.       From    : Positive;
  375.       Through : Natural)
  376.       return    Unbounded_String
  377.    is
  378.    begin
  379.       return
  380.         To_Unbounded_String
  381.           (Fixed.Delete (Source.Reference.all, From, Through));
  382.    end Delete;
  383.  
  384.    procedure Delete
  385.      (Source  : in out Unbounded_String;
  386.       From    : in Positive;
  387.       Through : in Natural)
  388.    is
  389.    begin
  390.       Source := To_Unbounded_String
  391.         (Fixed.Delete (Source.Reference.all, From, Through));
  392.    end Delete;
  393.  
  394.    -------------
  395.    -- Element --
  396.    -------------
  397.  
  398.    function Element
  399.      (Source : Unbounded_String;
  400.       Index  : Positive)
  401.       return   Character
  402.    is
  403.    begin
  404.       if Index <= Source.Reference.all'Last then
  405.          return Source.Reference.all (Index);
  406.       else
  407.          raise Strings.Index_Error;
  408.       end if;
  409.    end Element;
  410.  
  411.    ----------------
  412.    -- Find_Token --
  413.    ----------------
  414.  
  415.    procedure Find_Token
  416.      (Source : Unbounded_String;
  417.       Set    : Maps.Character_Set;
  418.       Test   : Strings.Membership;
  419.       First  : out Positive;
  420.       Last   : out Natural)
  421.    is
  422.    begin
  423.       Search.Find_Token (Source.Reference.all, Set, Test, First, Last);
  424.    end Find_Token;
  425.  
  426.    ----------
  427.    -- Free --
  428.    ----------
  429.  
  430.    procedure Free (X : in out String_Access) is
  431.       procedure Deallocate is
  432.          new Ada.Unchecked_Deallocation (String, String_Access);
  433.    begin
  434.       Deallocate (X);
  435.    end Free;
  436.  
  437.    ----------
  438.    -- Head --
  439.    ----------
  440.  
  441.    function Head
  442.      (Source : Unbounded_String;
  443.       Count  : Natural;
  444.       Pad    : Character := Space)
  445.       return   Unbounded_String
  446.    is
  447.    begin
  448.       return
  449.         To_Unbounded_String (Fixed.Head (Source.Reference.all, Count, Pad));
  450.    end Head;
  451.  
  452.    procedure Head
  453.      (Source : in out Unbounded_String;
  454.       Count  : in Natural;
  455.       Pad    : in Character := Space)
  456.    is
  457.    begin
  458.       Source := To_Unbounded_String
  459.         (Fixed.Head (Source.Reference.all, Count, Pad));
  460.    end Head;
  461.  
  462.    -----------
  463.    -- Index --
  464.    -----------
  465.  
  466.    function Index
  467.      (Source   : Unbounded_String;
  468.       Pattern  : String;
  469.       Going    : Strings.Direction := Strings.Forward;
  470.       Mapping  : Maps.Character_Mapping := Maps.Identity)
  471.       return     Natural
  472.    is
  473.    begin
  474.       return Search.Index (Source.Reference.all, Pattern, Going, Mapping);
  475.    end Index;
  476.  
  477.    function Index
  478.      (Source   : in Unbounded_String;
  479.       Pattern  : in String;
  480.       Going    : in Direction := Forward;
  481.       Mapping  : in Maps.Character_Mapping_Function)
  482.       return Natural
  483.    is
  484.    begin
  485.       return Search.Index (Source.Reference.all, Pattern, Going, Mapping);
  486.    end Index;
  487.  
  488.    function Index
  489.      (Source : Unbounded_String;
  490.       Set    : Maps.Character_Set;
  491.       Test   : Strings.Membership := Strings.Inside;
  492.       Going  : Strings.Direction  := Strings.Forward)
  493.       return   Natural
  494.    is
  495.    begin
  496.       return Search.Index (Source.Reference.all, Set, Test, Going);
  497.    end Index;
  498.  
  499.    function Index_Non_Blank
  500.      (Source : Unbounded_String;
  501.       Going  : Strings.Direction := Strings.Forward)
  502.       return   Natural
  503.    is
  504.    begin
  505.       return Search.Index_Non_Blank (Source.Reference.all, Going);
  506.    end Index_Non_Blank;
  507.  
  508.    ------------
  509.    -- Insert --
  510.    ------------
  511.  
  512.    function Insert
  513.      (Source   : Unbounded_String;
  514.       Before   : Positive;
  515.       New_Item : String)
  516.       return     Unbounded_String
  517.    is
  518.    begin
  519.       return
  520.         To_Unbounded_String
  521.           (Fixed.Insert (Source.Reference.all, Before, New_Item));
  522.    end Insert;
  523.  
  524.    procedure Insert
  525.      (Source   : in out Unbounded_String;
  526.       Before   : in Positive;
  527.       New_Item : in String)
  528.    is
  529.    begin
  530.       Source := To_Unbounded_String
  531.         (Fixed.Insert (Source.Reference.all, Before, New_Item));
  532.    end Insert;
  533.  
  534.    ------------
  535.    -- Length --
  536.    ------------
  537.  
  538.    function Length (Source : Unbounded_String) return Natural is
  539.    begin
  540.       return Source.Reference.all'Length;
  541.    end Length;
  542.  
  543.    ---------------
  544.    -- Overwrite --
  545.    ---------------
  546.  
  547.    function Overwrite
  548.      (Source    : Unbounded_String;
  549.       Position  : Positive;
  550.       New_Item  : String)
  551.       return      Unbounded_String is
  552.  
  553.    begin
  554.       return To_Unbounded_String
  555.         (Fixed.Overwrite (Source.Reference.all, Position, New_Item));
  556.    end Overwrite;
  557.  
  558.    procedure Overwrite
  559.      (Source    : in out Unbounded_String;
  560.       Position  : in Positive;
  561.       New_Item  : in String)
  562.    is
  563.    begin
  564.       Source := To_Unbounded_String
  565.         (Fixed.Overwrite (Source.Reference.all, Position, New_Item));
  566.    end Overwrite;
  567.  
  568.    ---------------------
  569.    -- Replace_Element --
  570.    ---------------------
  571.  
  572.    procedure Replace_Element
  573.      (Source : in out Unbounded_String;
  574.       Index  : Positive;
  575.       By     : Character)
  576.    is
  577.    begin
  578.       if Index <= Source.Reference.all'Last then
  579.          Source.Reference.all (Index) := By;
  580.       else
  581.          raise Strings.Index_Error;
  582.       end if;
  583.    end Replace_Element;
  584.  
  585.    -------------------
  586.    -- Replace_Slice --
  587.    -------------------
  588.  
  589.    function Replace_Slice
  590.      (Source   : Unbounded_String;
  591.       Low      : Positive;
  592.       High     : Natural;
  593.       By       : String)
  594.       return     Unbounded_String
  595.    is
  596.    begin
  597.       return
  598.         To_Unbounded_String
  599.           (Fixed.Replace_Slice (Source.Reference.all, Low, High, By));
  600.    end Replace_Slice;
  601.  
  602.    procedure Replace_Slice
  603.      (Source   : in out Unbounded_String;
  604.       Low      : in Positive;
  605.       High     : in Natural;
  606.       By       : in String)
  607.    is
  608.    begin
  609.       Source := To_Unbounded_String
  610.         (Fixed.Replace_Slice (Source.Reference.all, Low, High, By));
  611.    end Replace_Slice;
  612.  
  613.    -----------
  614.    -- Slice --
  615.    -----------
  616.  
  617.    function Slice
  618.      (Source : Unbounded_String;
  619.       Low    : Positive;
  620.       High   : Natural)
  621.       return   String
  622.    is
  623.       Result : String (1 .. High - Low + 1);
  624.  
  625.    begin
  626.       Result := Source.Reference.all (Low .. High);
  627.       return Result;
  628.    end Slice;
  629.  
  630.    ----------
  631.    -- Tail --
  632.    ----------
  633.  
  634.    function Tail
  635.      (Source : Unbounded_String;
  636.       Count  : Natural;
  637.       Pad    : Character := Space)
  638.       return   Unbounded_String is
  639.  
  640.    begin
  641.       return
  642.         To_Unbounded_String (Fixed.Tail (Source.Reference.all, Count, Pad));
  643.    end Tail;
  644.  
  645.    procedure Tail
  646.      (Source : in out Unbounded_String;
  647.       Count  : in Natural;
  648.       Pad    : in Character := Space)
  649.    is
  650.    begin
  651.       Source := To_Unbounded_String
  652.         (Fixed.Tail (Source.Reference.all, Count, Pad));
  653.    end Tail;
  654.  
  655.    ---------------
  656.    -- To_String --
  657.    ---------------
  658.  
  659.    function To_String (Source : Unbounded_String) return String is
  660.    begin
  661.       return Source.Reference.all;
  662.    end To_String;
  663.  
  664.    -------------------------
  665.    -- To_Unbounded_String --
  666.    -------------------------
  667.  
  668.    function To_Unbounded_String (Source : String) return Unbounded_String is
  669.       Result : Unbounded_String;
  670.  
  671.    begin
  672.       Result := (Reference => new String (1 .. Source'Length));
  673.       Result.Reference.all := Source;
  674.       return Result;
  675.    end To_Unbounded_String;
  676.  
  677.    function To_Unbounded_String (Length : in Natural)
  678.       return Unbounded_String
  679.    is
  680.       Result : Unbounded_String;
  681.  
  682.    begin
  683.       Result := (Reference => new String (1 .. Length));
  684.       return Result;
  685.    end To_Unbounded_String;
  686.  
  687.    ------------
  688.    -- Append --
  689.    ------------
  690.  
  691.    procedure Append
  692.      (Source   : in out Unbounded_String;
  693.       New_Item : in Unbounded_String)
  694.    is
  695.       S_Length : constant Integer := Source.Reference.all'Length;
  696.       Length   : constant Integer := S_Length + New_Item.Reference.all'Length;
  697.       Temp     : Unbounded_String := (Reference => new String (1 .. S_Length));
  698.  
  699.    begin
  700.       Temp.Reference.all := Source.Reference.all;
  701.       Source := (Reference => new String (1 .. Length));
  702.       Source.Reference.all (1 .. S_Length) := Temp.Reference.all;
  703.       Source.Reference.all (S_Length + 1 .. Length) := New_Item.Reference.all;
  704.    end Append;
  705.  
  706.    procedure Append
  707.      (Source   : in out Unbounded_String;
  708.       New_Item : in String)
  709.    is
  710.       S_Length : constant Integer := Source.Reference.all'Length;
  711.       Length   : constant Integer := S_Length + New_Item'Length;
  712.       Temp     : Unbounded_String := (Reference => new String (1 .. S_Length));
  713.  
  714.    begin
  715.       Temp.Reference.all := Source.Reference.all;
  716.       Source := (Reference => new String (1 .. Length));
  717.       Source.Reference.all (1 .. S_Length) := Temp.Reference.all;
  718.       Source.Reference.all (S_Length + 1 .. Length) := New_Item;
  719.    end Append;
  720.  
  721.    procedure Append
  722.      (Source   : in out Unbounded_String;
  723.       New_Item : in character)
  724.    is
  725.       S_Length : constant Integer := Source.Reference.all'Length;
  726.       Length   : constant Integer := S_Length + 1;
  727.       Temp     : Unbounded_String := (Reference => new String (1 .. S_Length));
  728.  
  729.    begin
  730.       Temp.Reference.all := Source.Reference.all;
  731.       Source := (Reference => new String (1 .. Length));
  732.       Source.Reference.all (1 .. S_Length) := Temp.Reference.all;
  733.       Source.Reference.all (S_Length + 1) := New_Item;
  734.    end Append;
  735.  
  736.    ---------------
  737.    -- Translate --
  738.    ---------------
  739.  
  740.    function Translate
  741.      (Source  : Unbounded_String;
  742.       Mapping : Maps.Character_Mapping)
  743.       return    Unbounded_String
  744.    is
  745.    begin
  746.       return
  747.         To_Unbounded_String (Fixed.Translate (Source.Reference.all, Mapping));
  748.    end Translate;
  749.  
  750.    procedure Translate
  751.      (Source  : in out Unbounded_String;
  752.       Mapping : Maps.Character_Mapping)
  753.    is
  754.    begin
  755.       Fixed.Translate (Source.Reference.all, Mapping);
  756.    end Translate;
  757.  
  758.    function Translate
  759.      (Source  : in Unbounded_String;
  760.       Mapping : in Maps.Character_Mapping_Function)
  761.       return    Unbounded_String
  762.    is
  763.    begin
  764.       return
  765.         To_Unbounded_String (Fixed.Translate (Source.Reference.all, Mapping));
  766.    end Translate;
  767.  
  768.    procedure Translate
  769.      (Source  : in out Unbounded_String;
  770.       Mapping : in Maps.Character_Mapping_Function)
  771.    is
  772.    begin
  773.       Fixed.Translate (Source.Reference.all, Mapping);
  774.    end Translate;
  775.  
  776.    ----------
  777.    -- Trim --
  778.    ----------
  779.  
  780.    function Trim
  781.      (Source : in Unbounded_String;
  782.       Side   : in Trim_End)
  783.       return   Unbounded_String
  784.    is
  785.    begin
  786.       return To_Unbounded_String (Fixed.Trim (Source.Reference.all, Side));
  787.    end Trim;
  788.  
  789.    procedure Trim
  790.      (Source : in out Unbounded_String;
  791.       Side   : in Trim_End)
  792.    is
  793.    begin
  794.       Fixed.Trim (Source.Reference.all, Side);
  795.    end Trim;
  796.  
  797.    function Trim
  798.      (Source : in Unbounded_String;
  799.       Left   : in Maps.Character_Set;
  800.       Right  : in Maps.Character_Set)
  801.       return   Unbounded_String
  802.    is
  803.    begin
  804.       return
  805.         To_Unbounded_String (Fixed.Trim (Source.Reference.all, Left, Right));
  806.    end Trim;
  807.  
  808.    procedure Trim
  809.      (Source : in out Unbounded_String;
  810.       Left   : in Maps.Character_Set;
  811.       Right  : in Maps.Character_Set)
  812.    is
  813.    begin
  814.       Fixed.Trim (Source.Reference.all, Left, Right);
  815.    end Trim;
  816.  
  817. end Ada.Strings.Unbounded;
  818.